package com.woniuxy.reservation.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.reservation.client.param.SearchTakeNumByConditionParam;
import com.woniuxy.reservation.client.result.TakeNumClientDto;
import com.woniuxy.reservation.client.takenumclient.TakeNumQueryClient;
import com.woniuxy.reservation.service.TakeNumService;
import com.woniuxy.reservation.service.servicedto.TakeNumServiceDto;
import com.woniuxy.reservation.service.serviceparam.SearchTakeNumByConditionServiceParam;
import common.WoniuPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

import java.util.List;

@RestController
public class TakeNumQueryClientApiImpl implements TakeNumQueryClient {
    @Autowired
    private TakeNumService takeNumService;
    @Override
    @Log("根据条件查询排队号")
    public Result searchTakeNumByCondition(SearchTakeNumByConditionParam param) {
        SearchTakeNumByConditionServiceParam searchTakeNumByConditionServiceParam = BeanUtil.toBean(param, SearchTakeNumByConditionServiceParam.class);
        WoniuPage<TakeNumServiceDto> woniuPage = takeNumService.searchTakeNumByCondition(searchTakeNumByConditionServiceParam);
        WoniuPage<TakeNumClientDto> page = BeanUtil.toBean(woniuPage, WoniuPage.class);
        return Result.success(page);
    }

    @Override
    public Result<List<TakeNumClientDto>> searchTakeNumByTableTypeId(Integer storeId, Integer tableTypeId) {
        List<TakeNumServiceDto> takeNumServiceDtos = takeNumService.searchTakeNumByTableTypeId(storeId, tableTypeId);
        List<TakeNumClientDto> takeNumClientDtos = BeanUtil.copyToList(takeNumServiceDtos, TakeNumClientDto.class);
        return Result.success(takeNumClientDtos);
    }
}
